'''
Created on Feb 21, 2010

@author: Jeff Shi
'''
# ----
# main
# ----

import sys

from Voting import voting_print, voting_eval, voting_read

# -----------
# Globals
# -----------
howmany = 0

# -----------
# InputReader
# -----------

class InputReader (object) :
    def read (self) :
        return raw_input()

# ------------
# OutputWriter
# ------------

class OutputWriter (object) :
    def write (self, a) :
        for w in a :            
            print w
        

def main () :
    """
    runs the program
    """
    howmany = int(raw_input())  # number of instances
    raw_input()  # This is a blank line
    for i in range(0,howmany) :
        voting_read(InputReader())
        voting_eval()
        voting_print(OutputWriter())
        if( i != howmany-1 ) :  # separates each case with a blank line, unless if this is the last case
            print

if __name__ == "__main__" :
    main()
